package com.fqcar.fqdf.ui.chargemap.view;

import android.content.Context;
import android.text.Html;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.fqcar.fqdf.R;
import com.fqdf.framework.android.util.AndroidUtils;
import com.fqdf.framework.android.util.CheckLogicUtil;
import com.fqdf.framework.android.util.Constants;

import butterknife.BindView;
import butterknife.ButterKnife;


public class StubViewHelper implements StubViewInterface {


    @BindView(R.id.main_back_iv)
    ImageView mainBackIv;
    @BindView(R.id.title_txt)
    TextView titleTxt;
    @BindView(R.id.main_car_plate_num)
    TextView mainCarPlateNum;
    @BindView(R.id.main_car_brand)
    TextView mainCarBrand;
    @BindView(R.id.main_car_state)
    TextView mainCarState;
    @BindView(R.id.main_car_mileage)
    TextView mainCarMileage;
    @BindView(R.id.main_car_battery)
    TextView mainCarBattery;
    @BindView(R.id.main_car_charge_state)
    TextView mainCarChargeState;
    @BindView(R.id.main_car_machine_state)
    TextView mainCarMachineState;
    @BindView(R.id.main_car_address)
    TextView mainCarAddress;
    @BindView(R.id.main_car_distance)
    TextView mainCarDistance;
    @BindView(R.id.main_car_state_desc)
    TextView mainCarStateDesc;
    @BindView(R.id.main_car_state_desc_time)
    TextView mainCarStateDescTime;
    @BindView(R.id.main_car_operation)
    TextView mainCarOperation;
    @BindView(R.id.icon_arrow_right_iv)
    ImageView iconArrowRightIv;
    @BindView(R.id.nav_btn)
    Button navBtn;
    @BindView(R.id.main_car_state_layout)
    RelativeLayout mainCarStateLayout;
    @BindView(R.id.stub_name_tv)
    TextView stubNameTv;
    @BindView(R.id.stub_state_tv)
    TextView stubStateTv;
    @BindView(R.id.stub_address_tv)
    TextView stubAddressTv;
    @BindView(R.id.stub_distance_tv)
    TextView stubDistanceTv;
    @BindView(R.id.stub_nav_btn)
    Button stub_nav_btn;
//    @BindView(R.id.main_bottom_llyt)
//    LinearLayout mainBottomLlyt;
    @BindView(R.id.car_layout)
    LinearLayout car_layout;
    @BindView(R.id.stub_layout)
    LinearLayout stub_layout;

    // 主界面的RootView
    private View mContentView;

    private Context mContext;

    public StubViewHelper(Context context, View contentView) {
        mContentView = contentView;
        mContext = context;
        ButterKnife.bind(this, contentView);
    }

    @Override
    public void showSelCarView() {
        car_layout.setVisibility(View.VISIBLE);
    }

    @Override
    public void hidenSelCarView() {
        car_layout.setVisibility(View.GONE);
    }

    @Override
    public void setTitle(String title) {
        titleTxt.setText(title);
    }


    @Override
    public void updateCarPlateNum(String carPlateNum) {
        mainCarPlateNum.setText(carPlateNum);
    }

    @Override
    public void updateCarBrand(String carBrand) {
        mainCarBrand.setText(carBrand);
    }

    @Override
    public void updateCarState(String carState) {
        mainCarState.setText(carState);
    }

    @Override
    public void updateCarMileage(String carMileage) {
        mainCarMileage.setText(carMileage);
    }

    @Override
    public void updateCarBattery(String carBattery) {
        mainCarBattery.setText(carBattery);
    }

    @Override
    public void updateCarCharingState(String carChargingState) {
        mainCarChargeState.setText(carChargingState);
    }

    @Override
    public void updateMachineState(String machineState) {
        mainCarMachineState.setText(machineState);
    }

    @Override
    public void updateCarAddress(String carAddress) {
        mainCarAddress.setText(carAddress);
    }

    @Override
    public void updateDistance(String distance) {
        mainCarDistance.setText(distance);
    }

    @Override
    public void updateCarStateDesc(String carStateDesc) {
        mainCarStateDesc.setText(carStateDesc);
    }

    @Override
    public void updateCarStateDescTime(String carStateDescTime) {

        mainCarStateDescTime.setText(!CheckLogicUtil.isEmpty(carStateDescTime) ? Html.fromHtml(carStateDescTime) : Constants.BLANK);
//        mainCarStateDescTime.setTextColor(AndroidUtils.getColor(mContext,textColor));
    }

    @Override
    public void updateOperation(String operation) {
        mainCarOperation.setText(operation);
    }

    @Override
    public void showCarNavBtn() {
        navBtn.setVisibility(View.VISIBLE);
    }

    @Override
    public void hiddenCarNavBtn() {
        navBtn.setVisibility(View.GONE);
    }

    @Override
    public void showArrowIcon() {
        iconArrowRightIv.setVisibility(View.VISIBLE);
    }

    @Override
    public void hiddenArrowIcon() {
        iconArrowRightIv.setVisibility(View.GONE);
    }

    @Override
    public void showStubView() {
        stub_layout.setVisibility(View.VISIBLE);
    }

    @Override
    public void hiddenStubView() {
        stub_layout.setVisibility(View.GONE);
    }

    @Override
    public void updateStubName(String stubName) {
        stubNameTv.setText(stubName);
    }

    @Override
    public void updateStubAddress(String stubAddress) {
        stubAddressTv.setText(stubAddress);
    }

    @Override
    public void updateStubDistance(String stubDistance) {
        stubDistanceTv.setText(stubDistance);
    }

    @Override
    public void updateStubState(String stubState) {
        stubStateTv.setText(stubState);
    }

    @Override
    public Context getContext() {
        return null;
    }
}
